#ifndef MOSES_CALL_H
#define MOSES_CALL_H

#include <cassert>
#include "Expr.h"
#include "Identifier.h"

namespace moses
{
	class Call : public Expr
	{
	public:
		MOSES_ITEM_VISITABLE()
		
		Call(Identifier *pIdentifier, ItemList<Expr> *pArgs)
		: m_pIdentifier(pIdentifier), m_pArgs(pArgs)
		{
		}
		
		virtual Value Evaluate(Runtime *pEnv)
		{
			Function *pFunc =
				pEnv->GetModule()->GetFunction(m_pIdentifier->GetString());
				
			assert(pFunc);
				 
			return pFunc->Call(pEnv, m_pArgs);
		}
		
		Identifier*		GetIdentifier()		{ return m_pIdentifier; }
		ItemList<Expr>*	GetArguments()		{ return m_pArgs; }
		
	private:
		Identifier		*m_pIdentifier;
		ItemList<Expr>	*m_pArgs;
		

	};
	
}

#endif